package com.zyht.common.json;

/**
 * 描述：响应ajax简单json对象<br>
 * 作者：ruibo <br>
 * 修改日期：2017年6月24日-下午9:45:16 <br>
 */
public class ResponseJSON implements Cloneable {

	private int state = 200;

	private String msg;

	private ResponseJSON() {
	}

	public static final int STATE_SUCCESS = 200;

	public static final int STATE_FAIL = 400;

	public static final int STATE_ERROR = 500;

	private static ResponseJSON response = new ResponseJSON();

	public static ResponseJSON create() {
		return response.clone();
	}
	
	public static ResponseJSON create(int state) {
		ResponseJSON json = response.clone();
		json.setState(state);
		return json;
	}
	
	public static ResponseJSON create(int state, String msg) {
		ResponseJSON json = create(state);
		json.setMsg(msg);
		return json;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@Override
	protected ResponseJSON clone() {
		ResponseJSON json;
		try {
			json = (ResponseJSON) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
			json = new ResponseJSON();
		}
		return json;
	}
}
